#ifndef xpack_math_avg
#define xpack_math_avg
#pragma push_macro("xuser")
#undef  xuser
#define xuser mixc::math_avg::inc
#include"define/base_type.hpp"
#include"define/nullref.hpp"
#include"interface/initializer_list.hpp"
#include"interface/unified_seq.hpp"
#include"macro/xexport.hpp"
#include"macro/xunlikely.hpp"
#include"math/sum.hpp"
#pragma pop_macro("xuser")

namespace mixc::math_avg::origin{
    template<class type_t>
    inline type_t avg(type_t const & left, type_t const & right){
        return (left + right) / 2;
    }

    template<class item_t, class avg_t = item_t, class list_t = inc::initializer_list<item_t>>
    requires(inc::can_unified_seqlizex<list_t, item_t>)
    inline avg_t avg(list_t && list){
        auto ary        = inc::unified_seq<list_t>(list);
        auto len        = ary->length();
        if (len == 0){
            return {};
        }
        else{
            auto sum    = inc::sum<item_t, avg_t>(ary);
            auto result = sum / len;
            return result;
        }
    }
}

#endif

xexport_space(mixc::math_avg::origin)